<template>
  <div>
    <a-card :bordered="false">
      <div class="page_title">
        <div class="icon_box">
          <i class="iconfont icon-31shouyexuanzhong"></i>
        </div>

        <span class="name">数据填报</span>
      </div>
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <!-- <div class="header_left">
          <div class="header_left_top">
            <div class="icon_box">
              <i class="iconfont icon-31shouyexuanzhong"></i>
            </div>
            <div>
              <span class="name">排放数据填报</span>
              <p></p>
            </div>
          </div>
        </div> -->

        <!-- 操作按钮区域 -->
        <div class="table-operator" style="border-top: 5px">
          <a-dropdown v-if="selectedRowKeys.length > 0">
            <a-menu slot="overlay" @click="handleMenuClick">
              <a-menu-item key="1">
                <a-icon type="delete" @click="batchDel" />
                删除
              </a-menu-item>
              <a-menu-item key="2">
                <a-icon type="lock" @click="batchFrozen('2')" />
                冻结
              </a-menu-item>
              <a-menu-item key="3">
                <a-icon type="unlock" @click="batchFrozen('1')" />
                解冻
              </a-menu-item>
            </a-menu>
            <a-button style="margin-left: 8px">
              批量操作
              <a-icon type="down" />
            </a-button>
          </a-dropdown>
          <!-- <j-super-query :fieldList="superQueryFieldList" @handleSuperQuery="handleSuperQuery"/> -->
        </div>
        <!-- 表单搜索 -->
        <a-form class="form_" layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :span="4">
              <a-form-item>
                <a-tooltip :trigger="['focus']" placement="bottomLeft" overlay-class-name="numeric-input">
                  <!-- <span v-if="queryParam.username" slot="title" class="numeric-input-title">
                  {{ queryParam.username !== "-" ? formatNumber(queryParam.username) : "-" }}
                </span> -->
                  <template slot="title"> 请输入账号查询 </template>
                  <a-input placeholder="请输入账号查询" v-model="queryParam.username"></a-input>
                </a-tooltip>
              </a-form-item>
            </a-col>
            <a-col :span="4">
              <a-form-item class="ant-form-item">
                <a-select v-model="queryParam.sex" placeholder="请选择性别">
                  <a-select-option value="">请选择</a-select-option>
                  <a-select-option value="1">男</a-select-option>
                  <a-select-option value="2">女</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <template v-if="toggleSearchStatus">
              <a-col :span="4">
                <a-form-item>
                  <a-input placeholder="请输入真实名字" v-model="queryParam.realname"></a-input>
                </a-form-item>
              </a-col>
              <a-col :span="4">
                <a-form-item>
                  <a-input placeholder="请输入手机号码查询" v-model="queryParam.phone"></a-input>
                </a-form-item>
              </a-col>
              <a-col :span="4">
                <a-form-item>
                  <a-select v-model="queryParam.status" placeholder="请选择">
                    <a-select-option value="">请选择</a-select-option>
                    <a-select-option value="1">正常</a-select-option>
                    <a-select-option value="2">冻结</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
            </template>
            <a-col :span="4">
              <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button class="last" type="primary" @click="searchReset" icon="reload">重置</a-button>
                <a @click="handleToggleSearch" style="margin-left: 8px">
                  {{ toggleSearchStatus ? "收起" : "展开" }}
                  <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
                </a>
              </span>
            </a-col>
          </a-row>
        </a-form>

      </div>

      <!-- table区域-begin -->
      <div>
        <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
          <i class="anticon anticon-info-circle ant-alert-icon"></i>已选择&nbsp;<a style="font-weight: 600">{{
            selectedRowKeys.length
          }}</a>项&nbsp;&nbsp;
          <a style="margin-left: 24px" @click="onClearSelected">清空</a>
        </div>

        <a-table ref="table" bordered size="middle" rowKey="id" :columns="columns" :dataSource="dataSource"
          :pagination="ipagination" :loading="loading" :rowSelection="{
            selectedRowKeys: selectedRowKeys,
            onChange: onSelectChange,
          }" @change="handleTableChange">
          <template slot="avatarslot" slot-scope="text, record, index">
            <div class="anty-img-wrap">
              <a-avatar shape="square" :src="getAvatarView(record.avatar)" icon="user" />
            </div>
          </template>
          <span slot="status" slot-scope="text">
            <span v-if="text.privateStatus == 1"><a-badge color="#a7a8ad" />{{
              text.privateStatus_dictText
            }}</span>
            <span v-if="text.privateStatus == 2"><a-badge color="#ff4d4f" />{{
              text.privateStatus_dictText
            }}(<el-tag type="info" size="mini">{{
  text.todoUsers.replace('"', "").replace('"', "")
}}</el-tag>)</span>
            <span v-if="text.privateStatus == 3"><a-badge color="#f5a623" />{{
              text.privateStatus_dictText
            }}</span>
            <span v-if="text.privateStatus == 4"><a-badge color="#4bc076" />{{
              text.privateStatus_dictText
            }}</span>
          </span>
          <span slot="action" slot-scope="text, record">
            <a @click="handleInfo(record)">查看</a>
            <a-divider type="vertical" v-if="record.privateStatus == 1 || record.privateStatus == 3" />
            <a @click="fillTask(record)" v-if="record.privateStatus == 1 || record.privateStatus == 3">填报</a>
            <a-divider type="vertical" v-if="record.privateStatus == 1 || record.privateStatus == 3" />
            <!-- <a>发起审核</a>
            <a-divider type="vertical" />
            <a>审批历史</a> -->
            <span v-if="record.privateStatus == 1 || record.privateStatus == 3">
              <act-custom-apply-btn @success="loadData" :data-id="record.busiFormId" :serviceName="serviceName"
                :variables="record"></act-custom-apply-btn>
            </span>

            <a-divider type="vertical" v-if="record.privateStatus != 1" />
            <act-historic-detail-btn v-if="record.privateStatus != 1"
              :data-id="record.busiFormId"></act-historic-detail-btn>
          </span>
        </a-table>
        <FillInfo ref="modalForm" @ok="modalFormOk"></FillInfo>
      </div>
    </a-card>
  </div>
</template>


<script>
// import UserModule from "./User/UserModal.vue"
import FillInfo from "./FillTask/FillInfo.vue";
import { ListMixin } from "@/mixins/ListMixin";
import { putAction, getFileAccessHttpUrl } from "@/api/manage";
import ActApplyBtn from "@views/flowable/components/ActApplyBtn";
import ActCustomApplyBtn from "@views/flowable/components/ActCustomApplyBtn";
import ActCancelBtn from "@views/flowable/components/ActCancelBtn";
import ActHandleBtn from "@views/flowable/components/ActHandleBtn";
import ActHistoricDetailBtn from "@views/flowable/components/ActHistoricDetailBtn";


export default {
  name: "UserList",
  mixins: [ListMixin],
  data() {
    return {
      description: "这是用户管理页面",
      columns: [
        {
          title: "任务名称",
          align: "left",
          dataIndex: "name",

          sorter: true,
        },

        {
          title: "核算标准",
          align: "left",
          dataIndex: "industryId_dictText",

          sorter: true,
        },
        {
          title: "核算周期",
          align: "left",

          dataIndex: "fillingTime",
        },
        {
          title: "创建人",
          align: "left",
          dataIndex: "createBy_dictText",
        },
        {
          title: "创建时间",
          align: "left",
          dataIndex: "createTime",

          sorter: true,
        },
        {
          title: "填报任务状态",
          align: "left",
          scopedSlots: { customRender: "status" },
        },

        {
          title: "操作",
          dataIndex: "action",
          scopedSlots: { customRender: "action" },
          align: "left",
        },
      ],
      queryParam: {},
      recycleBinVisible: false,

      superQueryFieldList: [
        { type: "input", value: "username", text: "用户账号" },
        { type: "input", value: "realname", text: "用户姓名" },
        {
          type: "select",
          value: "sex",
          dbType: "int",
          text: "性别",
          dictCode: "sex",
        },
      ],

      url: {
        list: "/accounting/personal-informant/queryListByInformantUserId",
        // list: "/accounting/task/queryTaskListByUserId",
        delete: "/sys/user/delete",
        deleteBatch: "/sys/user/deleteBatch",
        exportXlsUrl: "/sys/user/exportXls",
        importExcelUrl: "sys/user/importExcel",
      },
      serviceName: "personalInformantService",
    };
  },
  components: {
    FillInfo,
    ActCustomApplyBtn,
    ActApplyBtn,
    ActCancelBtn,
    ActHandleBtn,
    ActHistoricDetailBtn,
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG["domianURL"]}/${this.url.importExcelUrl}`;
      // return "";
    },
  },
  methods: {
    fillTask(record) {
      this.$router.push(`/accounting/filltask2?taskId=${record.id}`);
    },
    passwordModalOk() { },
    modalFormOk() { },
    getAvatarView: function (avatar) {
      return getFileAccessHttpUrl(avatar);
    },
    handleChangePassword(username) {
      this.$refs.passwordmodal.show(username);
    },
    handleFrozen: function (id, status, username) {
      let that = this;
      //TODO 后台校验管理员角色
      if ("admin" == username) {
        that.$message.warning("管理员账号不允许此操作！");
        return;
      }
      frozenBatch({ ids: id, status: status }).then((res) => {
        if (res.success) {
          that.$message.success(res.message);
          that.loadData();
        } else {
          that.$message.warning(res.message);
        }
      });
    },
  },
};
</script>

<style lang="scss">
.select_flex {
  display: flex;
}

.statu1 {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  display: inline-block;
  background: #a7a8ad;
}

.statu2 {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  display: inline-block;
  background: #ff4d4f;
}

.statu3 {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  display: inline-block;
  background: #f5a623;
}

@import "@/assets/css/listcommon.scss";
</style>